<template>
<div>
   <group-title>线网报表</group-title>    
    <grid>
      <!-- <grid-item :label="i" v-for="i in ['日报表','月报表']" :key="i">
        <img slot="icon" src="../assets/grid_icon.png">
      </grid-item> -->
      <grid-item :link="{ path: '/net/daily'}" label="日报表">
        <img slot="icon" src="../../assets/grid_icon.png">
      </grid-item>
      <grid-item :link="{ path: '/net/month'}" label="月报表">
        <img slot="icon" src="../../assets/grid_icon.png">
      </grid-item>
    </grid>
    <transition name="router-slid" mode="out-in">
            <router-view></router-view>
    </transition>
    <br/> 
    <br/>  
    <br/> 
    <br/> 
    <br/> 
    <br/>  
    <br/> 
    <br/>   
  <el-alert   title="日报微应用介绍" type="info"  center description="可以选择日报或者月报进行查看" ></el-alert>
  </div>
</template>
<script>
import "assets/iconfont/iconfont.css";
import vue from "vue";
import {
   Grid, GridItem, GroupTitle 
} from "vux";
import {
  getDDUserInfo,
  getUtList,
  updateUt,
  getXZDBList
} from "src/service/getData";
export default {
  components: {
    Grid,
    GridItem,
    GroupTitle
  },
  data() {
    return {
      taskList: [],
      xzdbList: [],
      infocode: "",
      userInfo: null,
      userCode:""
    };
  },
  watch: {
   infocode: function(value, oldvale) {
      this.getUserInfo();
    }
    
  },
  mounted() {
  },
  created() {
    this.getDDInfo();
  },
  methods: {
    getDDInfo() {
       if (process.env.NODE_ENV == "development") {
        this.infocode = "123";
      } else {
        var _this = this;
        var ddurl = document.URL.split("#")[0];
        var query = { ddurl: ddurl };
        var dd = window.dd;
        var res_corpId = "ding786250c40f654fe4";
        console.log("dd", dd);
        dd.ready(function() {
          dd.runtime.permission.requestAuthCode({
            corpId: "ding786250c40f654fe4",
            onSuccess: function(info) {
              console.log("dd_info_code:" + info.code);
              _this.infocode = info.code;
            },
            onFail: function(err) {
              alert("requestAuthCode——登录验证失败，请联系管理员。");
            }
          });
        });
     }
      console.log("this.infocode :" + this.infocode);
    },
    async getUserInfo() {
      //console.log("1");
      if (this.infocode) {
      //  console.log("2",this.infocode);
        getDDUserInfo(this.infocode).then(response => {
        //  console.log("3response",response);
          if (response.status == 200) {
            this.userInfo = response.data;          
            //console.log("4userInfo", this.userInfo);
            this.userCode= this.userInfo.user_code;
           // console.log("5this.userCode",this.userCode);
            this.$store.commit("setUser",this.userInfo);
           // console.log("setUser", this.userInfo);
          } else {
            alert("数据加载失败，请重试！");
          }
        });
      }
    }    
  }
};
</script>